﻿using Shop.RemoteModel.PageTemplate.Model;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/page/template/{name}")]
    internal class PageTemplateApi : ApiController
    {
        private readonly IPageTemplateService _Service;

        public PageTemplateApi ( IPageTemplateService service )
        {
            this._Service = service;
        }

        public long Add ( PageTemplateAdd datum )
        {
            return this._Service.Add(datum);
        }

        public void Delete ( [NumValidate("shop.page.template.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }
        public bool Enable ( [NumValidate("shop.page.template.id.error", 1)] long id )
        {
            return this._Service.Enable(id);
        }

        public PageTemplateDto Get ( [NumValidate("shop.page.template.id.error", 1)] long id )
        {
            return this._Service.Get(id);
        }

        public PagingResult<PageTemplateDto> Query ( PagingParam<PageTemplateQuery> param )
        {
            return this._Service.Query(param);
        }

        public bool Set ( LongParam<PageTemplateSet> param )
        {
            return this._Service.Set(param.Id, param.Value);
        }
    }
}
